

#pragma once
#include "resource.h"
#include "./uilib/ListCtrl.h"

#define WM_MSG_FILE_ACCEPT	WM_USER+1008
#define WM_MSG_FILE_HANGUP	WM_USER+1009
#define IDC_BUTTON_FILE_ACCEPT	7777
#define IDC_BUTTON_FILE_HANGUP	8777
#define IDC_BUTTON_FILE_CANCEL	9777
#define IDC_PROCESSBAR_CTRL		6777

struct ftstatus
{
	string	sid;
	bool	bting;
	long	size;
	long	offset;
};
	 
typedef map<int,ftstatus>		ftmap;
class FileDlg : public CAxDialogImpl<FileDlg>,public CUpdateUI<FileDlg>,public CMessageFilter,public CIdleHandler
{
public:
	enum { IDD = IDD_DIALOG_FILE };
public:
	CListCtrl			m_wndListCtrl;
	ftmap				m_sidmap;
	JID					m_destjid;
	FileDlg()
	{
		m_wndListCtrl.RegisterClass();
	}
	virtual BOOL PreTranslateMessage(MSG *pMSG)
	{
		if(m_hWnd)
			return CWindow::IsDialogMessage(pMSG);
		return false;
	}
	virtual BOOL OnIdle()
	{
		return false;
	}
	BEGIN_UPDATE_UI_MAP(FileDlg)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(FileDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		NOTIFY_HANDLER_EX(IDC_CUSTOM_LIST, LCN_HYPERLINK, OnListHyperLink)
		//COMMAND_RANGE_HANDLER_EX(IDC_BUTTON_FILE_ACCEPT,IDC_BUTTON_FILE_ACCEPT+999,OnAccept)
		//COMMAND_RANGE_HANDLER_EX(IDC_BUTTON_FILE_HANGUP,IDC_BUTTON_FILE_HANGUP+999,OnHangUp)
		//COMMAND_RANGE_HANDLER_EX(IDC_BUTTON_FILE_CANCEL,IDC_BUTTON_FILE_CANCEL+999,OnCancel)
		CHAIN_MSG_MAP(CUpdateUI<FileDlg>)
	END_MSG_MAP()
	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);
	LRESULT OnAccept(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnHangUp(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnListHyperLink( LPNMHDR lpNMHDR );

public:
	void AddRecvItem(string file,long size,string sid);
	void AddSendItem(string file,long size,string sid);
	void DelItem(string sid);
};